package com.platform.module.dao.mapper;

import com.platform.module.dao.entity.TbUserPay;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * <p>
 * 用户充值提现表 Mapper 接口
 * </p>
 *
 * @author ZM
 * @since 2025-01-07
 */
public interface TbUserPayMapper extends BaseMapper<TbUserPay> {

    @Select("select sum(imoney) from tb_user_pay where user_id = #{userId} and itype = #{itype} and isuccess = #{isSuccess} and TO_DAYS(ccreated_time) = TO_DAYS(#{createTime})")
    BigDecimal sumImoneyByUserIdAndItypeAndIsSuccessAndCcreateTime(Long userId, Integer itype, Integer isSuccess, LocalDate createTime);

    @Select("select sum(imoney) from tb_user_pay where user_id = #{userId} and itype = #{itype} and isuccess = #{isSuccess} and ccreated_time between #{cumulativeStartTime} and #{cumulativeExpiredTime}")
    BigDecimal sumImoneyByUserIdAndItypeAndIsSuccessAndCcreateTimeBetween(Long userId, Integer itype, Integer isSuccess, LocalDateTime cumulativeStartTime, LocalDateTime cumulativeExpiredTime);
}
